﻿/* * 版 本 PIT-ADMS V7.0.3 敏捷开发框架
 * Copyright (c) 2013-2018 Hexagon PPM
 * 创建人：超级管理员
 * 日  期：2022-02-24 11:10
 * 描  述：对象类型
 */
var refreshGirdData;
var ProjectId = request('ProjectId');
var bootstrap = function ($, learun) {
    "use strict";
    var page = {
        init: function () {
            page.initGird();
            page.bind();
        },
        bind: function () {
            //模板导出
            $('#lr_export').on('click', function () {
                var exportData = $('#dataTree').lrtreeSet("getCheckNodesEx");
                if (exportData.length == 0) {
                    learun.alert.warning('请至少选择一个要导出模板的对象类型！');
                    return false;
                }
                var IsExportData = document.getElementById("IsExportData").checked;
                var objectTypeIDs = "";
                for (var i = 0; i < exportData.length; i++) {
                    objectTypeIDs += exportData[i].id + ",";
                }
                objectTypeIDs = objectTypeIDs.substring(0, objectTypeIDs.length - 1);
                var TagNumber = $('#TagNumber').val();
                learun.loading(true, "导出中...");
                var iframeUrl = top.$.rootUrl + '/ZZDT_EC/ec_objecttype/ExportToExcel?ProjectId=' + ProjectId + "&IsExportData=" + IsExportData + "&objectTypeIDs=" + objectTypeIDs + "&TagNumber=" + TagNumber;
                learun.loading(true, "Excel读取中...");
                var body = document.getElementsByTagName("body")[0];
                var downloadIframe = document.createElement("iframe");
                downloadIframe.setAttribute("src", iframeUrl);
                downloadIframe.setAttribute("style", "display:none;")
                body.appendChild(downloadIframe);
                learun.loading(false);
            });
            //查询
            $('#btn_Search').on('click', function () {
                var ObjectTypeName = $('#ObjectTypeName').val();
                var TagNumber = $('#TagNumber').val();
                $('#dataTree').lrtree({
                    url: top.$.rootUrl + '/ZZDT_EC/ec_objecttype/GetTreeDataByFilter',
                    param: { ProjectId: ProjectId, ObjectTypeName: ObjectTypeName, TagNumber: TagNumber, isShowCheck: true },
                    nodeClick: function (item) {

                    }
                });
            });
        },
        initGird: function () {
            // 初始化左侧树形数据
            $('#dataTree').lrtree({
                url: top.$.rootUrl + '/ZZDT_EC/ec_objecttype/GetTreeDataByFilter',
                param: { ProjectId: ProjectId, isShowCheck: true  },
                nodeClick: function (item) {
                    
                }
            });
        },
        
    };
    page.init();
}
